﻿using System;
using ExFlash.Records;

namespace ExFlash.Tags
{
    public class ImportAssetsTag : Tag
    {
        protected int SwfVersion;

        public StringRecord URL
        {
            get;
            protected set;
        }

        public UInt16 Count
        {
            get;
            protected set;
        }

        public AssetData[] Assets
        {
            get;
            protected set;
        }

        public ImportAssetsTag(int len, int version, Int32 offset)
            : this(TagCodes.ImportAssets,len,version, offset)
        {
        }

        protected ImportAssetsTag(TagCodes code, int len, int version, Int32 offset)
            : base(code,len, offset)
        {
            SwfVersion = version;
        }

        public override void SwfDeserialize(BinaryBitReader reader)
        {
            URL = new StringRecord(SwfVersion);
            URL.SwfDeserialize(reader);

            Count = reader.ReadUInt16();

            Assets = new AssetData[Count];

            for (int i = 0; i < Count; i++)
            {
                Assets[i] = new AssetData(SwfVersion);
                Assets[i].SwfDeserialize(reader);
            }
        }

        public override void SwfSerialize(byte[] arr, ref int offset)
        {
            throw new NotImplementedException();
        }
    }
}
